package net.xiduth.game.player.dialogues.impl;

import java.text.NumberFormat;

import net.xiduth.game.player.content.misc.PvPArtifacts;
import net.xiduth.game.player.dialogues.Dialogue;
import net.xiduth.utils.npc.DialAnims;

/**
 * @author Tyluur <itstyluur@gmail.com>
 * @since 2012-08-23
 */
public class ArtefactExchange extends Dialogue {

	int npcId;

	@Override
	public void start() {
		npcId = (Integer) parameters[0];
		if (PvPArtifacts.hasArtefacts(player))
			sendNPCDialogue(npcId, DialAnims.HAPPY_TALKING.getId(), "Glorious, brave warrior! I see you have found some of the ancient artefacts my brother and I are seeking.");
		else {
			sendNPCDialogue(npcId, CALM_TALKING, "Greetings, what may I do for you on this glorious day?");
			stage = 3;
		}
	}

	@Override
	public void run(int interfaceId, int option) {
		switch(stage) {
		case -1:
			sendNPCDialogue(npcId, CALM_TALKING, "You wouldn't be willing to sell them to me?");
			stage = 0;
			break;
		case 0:
			sendOptionsDialogue("Select an Option", "Sure, I can do that.", "No, sorry.");
			stage = 1;
			break;
		case 1:
			switch(option) {
			case OPTION_1:
				sendPlayerDialogue(CALM_TALKING, "Sure, I can do that.");
				stage = 2;
				break;
			case OPTION_2:
				end();
				break;
			}
			break;
		case 2:
			player.getDialogueManager().startDialogue("SimpleMessage", "You sold the artefacts for " + NumberFormat.getIntegerInstance().format(PvPArtifacts.getArtifactReward(player)) + " coins.");
			PvPArtifacts.convertToCoins(player);
			break;
		case 3:
			sendOptionsDialogue("Select an Option", "How do I get artefacts?", "Never mind.");
			stage = 4;
			break;
		case 4:
			switch(option) {
			case OPTION_1:
				sendNPCDialogue(npcId, DialAnims.HAPPY_TALKING.getId(), "Oh, how happy I am to tell you! You can get a variety of artefacts based on your wilderness EP level. The higher your EP is, the better chance you have at getting an artefact.");
				stage = 5;
				break;
			case OPTION_2:
				end();
				break;
			}
			break;
		case 5:
			sendNPCDialogue(npcId, DialAnims.HAPPY_TALKING.getId(), "Your EP raises when you are in the wilderness without leaving for a long time.");
			stage = -2;
			break;
		default:
			end();
			break;
		}
	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub

	}

}
